package com.atguigu.gmall.common.util;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author:lyd
 * @Date:2023/9/1 19:30
 * @Version:1.0
 * @Description 获取旧的请求
 **/
public class ReqUtil {
    public static HttpServletRequest getOldRequest() {
        //RequestContextHolder里面有当前线程所有的数据
        ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();

        if (requestAttributes != null) {
            //获取旧的请求
            HttpServletRequest request = requestAttributes.getRequest();
            //拿到旧的请求里面所有的请求头
            return request;
        }
      return null;
    }


}
